﻿using NUnit.Framework;
using Sasa.QualityTools.CodeAnalysis.Core.Requests;
using Sasa.QualityTools.CodeAnalysis.Core.Services;
using Sasa.QualityTools.CodeAnalysis.Core.Services.CodeAnalysis;
using System;

namespace Sasa.QualityTools.CodeAnalysis.Core.Tests.Unit.Services
{
    [TestFixture]
    public class CodeAnalysisServiceTest
    {
        private CodeAnalysisService testee;


        [SetUp]
        public void SetUp()
        {
            testee = new CodeAnalysisService();
        }

        [Test]
        [Description("Execute should throw an exception when it is passed null.")]
        public void TestExecuteWithNull()
        {
            Assert.Throws<ArgumentNullException>(() => testee.Execute(null));
        }

        [Test]
        [Description("CreateCodeAnalyzer should return an instance of the AssemblyAnalyzer class when it is passed the AssemblyAnalysisRequest.")]
        public void TestCreateCodeAnalyzerForAssembly()
        {
            var request = new AssemblyAnalysisRequest();
            Assert.IsInstanceOf<AssemblyAnalyzer>(testee.CreateCodeAnalyzer(request));
        }

        [Test]
        [Description("CreateCodeAnalyzer should return an instance of the FxCopProjectAnalyzer class when it is passed the FxCopProjectAnalysisRequest.")]
        public void TestCreateCodeAnalyzerForFxCopProject()
        {
            var request = new FxCopProjectAnalysisRequest();
            Assert.IsInstanceOf<FxCopProjectAnalyzer>(testee.CreateCodeAnalyzer(request));
        }
    }
}
